package leetcode_1_200;

import node.ListNode;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class LeeCode_147 {
    public static void main(String[] args) {

    }
    private static ListNode insertionSortList(ListNode head) {
        if (head == null)
            return null;
        List<ListNode> list = new ArrayList<>();
        while (head != null) {
            list.add(head);
            head = head.next;
        }
        int len = list.size();
        list.sort(Comparator.comparingInt(o -> o.val));
        for (int i = 0; i < len - 1; i++) {
            list.get(i).next = list.get(i + 1);
        }
        list.get(len - 1).next = null;
        return list.get(0);
    }
}
